package com.alks.function.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.FormingFeedingRequest;
import com.alks.function.data.request.FormingProductionRequest;
import com.alks.function.service.FormingProductionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;

@ApiRestController("/production")
@Api(tags = "成型生产查询")
@Slf4j
public class FormingProductionController {

    @Autowired
    private FormingProductionService formingProductionService;

    @PostMapping("/getFormingProduction")
    @ApiOperation("选择指令")
    @WebLogger
    public ResponseInfo getFormingProduction(@RequestBody FormingProductionRequest request){
        return formingProductionService.getStyleDetail(request);
    }

    @ApiOperation("号码明细")
    @GetMapping("/getNumberDetail")
    @WebLogger
    public ResponseInfo getNumberDetail(@RequestParam(value = "lotNo") String lotNo){
        return formingProductionService.getNumberDetail(lotNo);
    }

    @ApiOperation("指令投料明细")
    @GetMapping("/getThrowDetail")
    @WebLogger
    public ResponseInfo getThrowDetail(@RequestParam(value = "lotNo") String lotNo){
        return formingProductionService.getThrowDetail(lotNo);
    }

    @ApiOperation("指令产料明细")
    @GetMapping("/getProductionDetail")
    @WebLogger
    public ResponseInfo getProductionDetail(@RequestParam(value = "lotNo") String lotNo){
        return formingProductionService.getProductionDetail(lotNo);
    }

    @ApiOperation("查询线别")
    @GetMapping("/getLine")
    @WebLogger
    public ResponseInfo getLine(){
        return formingProductionService.getLines();
    }

    @ApiOperation("成型投料明细")
    @PostMapping("/getFeedingDetails")
    @WebLogger
    public ResponseInfo getFeedingDetails(@RequestBody FormingFeedingRequest request){
        return formingProductionService.getFeedingDetails(request);
    }

    @ApiOperation("成型产料明细")
    @PostMapping("/getOutputDetails")
    @WebLogger
    public ResponseInfo getOutputDetails(@RequestBody FormingFeedingRequest request){
        return formingProductionService.getOutputDetails(request);
    }

    @ApiOperation("成型日报表")
    @PostMapping("/exportDailyReport")
    @WebLogger
    public void exportDailyReport(@RequestBody FormingFeedingRequest request, HttpServletResponse response){
        formingProductionService.exportDailyReport(request,response);
    }

    @ApiOperation("成型月报表")
    @PostMapping("/exportMonthlyReport")
    @WebLogger
    public ResponseInfo exportMonthlyReport(@RequestBody FormingFeedingRequest request, HttpServletResponse response){
        formingProductionService.exportMonthlyReport(request,response);
        return ResponseInfo.fileLoading();
    }
}
